; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt -passes=globalopt < %s -S | FileCheck %s

; Check that we don't try to set a global initializer to a value of a different type.
; In this case, we were trying to set @0's initializer to be ptr null.

%T = type { ptr }

@0 = internal global ptr null

define void @a() {
; CHECK-LABEL: @a(
; CHECK-NEXT:    ret void
;
  %1 = tail call ptr @_Znwm(i64 8)
  store ptr null, ptr %1, align 8
  store ptr %1, ptr @0, align 8
  %2 = load ptr, ptr @0, align 8
  %3 = load atomic i64, ptr %2 acquire, align 8
  ret void
}

declare ptr @_Znwm(i64)
